package cn.edu.jxau.test;

import java.util.Objects;

import cn.edu.jxau.util.LinkedStack;
import cn.edu.jxau.util.Stack;

public class Main {

	public static void main(String[] args) {

		char[] str = "abc".toCharArray();
		combination(str);
	}

	public static void combination(char[] str) {

		Objects.requireNonNull(str, "参数str不能为null");
		if (str.length == 0) {
			return;
		}
		Stack<Character> stack = new LinkedStack<>();
		for (int i = 1; i <= str.length; i++) {
			combination(str, 0, i, stack);
		}
	}

	private static void combination(char[] str, int begin, int m, Stack<Character> stack) {

		if (m == 0) {
			System.out.println(stack);
			return;
		}
		if (begin >= str.length) {
			return;
		}
		stack.push(str[begin]);
		combination(str, begin + 1, m - 1, stack);
		stack.pop();
		combination(str, begin + 1, m, stack);
	}
}